    
    var start=document.getElementById('new');
    var flying=true;
    var birds={
        stepx:152,
        stepy:0,
        x: bird.offsetLeft,
        y: bird.offsetTop
    }

    var sky={
        x:0
    }

    var count=0;
    var bg=setInterval(function(){
        sky.x-=2;
        game.style.backgroundPosition=sky.x+'px';
        birds.stepy+=1;
        birds.y+=birds.stepy;
        if(birds.stepy>=10){
            birds.stepy=-10;
            birds.y+=birds.stepy;
        }
        bird.style.top=birds.y+'px';
    },30)

    start.onclick=function(){
    start.style.display='none';
    co.innerHTML=count;
    results.innerHTML=count;
    clearInterval(bg);//清除自动飞
    birds.stepy=0;//数值初始化
    setInterval(function(){
        if(flying){
            sky.x-=5;
            game.style.backgroundPositionX=sky.x+'px';
            birds.y+=birds.stepy;
            birds.x=birds.stepx;
            birds.stepy+=1;
            if (birds.y<=0) {
                flying=false;
                mask.style.display="block";
                success.style.display="block";
                co.style.display="none";
            }
            if(birds.y+bird.offsetHeight>=600) {
                flying=false;
                mask.style.display='block';
                success.style.display="block";
                co.style.display="none";
            }
        bird.style.top=birds.y+'px';
        bird.style.left=birds.x+'px';
        }
    },40)

    game.onclick=function () {
        birds.stepy=-8;//点一次飞一下
    }
    function createzz(x) {//柱子
        var zz={};
        zz.x=x;
        zz.uheight=50+Math.ceil(Math.random()*200);
        zz.dheight=600-350-zz.uheight;

        var uzz=document.createElement('div');
        uzz.style.height=zz.uheight+'px';
        uzz.style.width='52px';
        uzz.style.position='absolute';
        uzz.style.left=zz.x+'px';
        uzz.style.background='url(./images/juan_up.png) no-repeat center bottom';
        uzz.style.top='0px';
        game.appendChild(uzz);
        var dzz=document.createElement('div');
        dzz.style.width='52px';
        dzz.style.height=zz.dheight+'px';
        dzz.style.position='absolute';
        dzz.style.left=zz.x+'px';
        dzz.style.background='url(./images/juan_down.png) no-repeat ';
        dzz.style.top=zz.uheight+350+'px';
        game.appendChild(dzz);
        setInterval(function () {//柱子移动
            if(flying) {
                zz.x-=5;
                uzz.style.left=zz.x+'px';
                dzz.style.left=zz.x+'px';
            if(zz.x<=-52){
            zz.x=1450;
            }
            if(zz.x>=0 && birds.x >= zz.x+52){
                count++;
                co.innerHTML=count;
                results.innerHTML=count;
            }

            var ucheck=birds.x + 30 > zz.x && birds.x < zz.x + 12 && birds.y <= zz.uheight;
            var dcheck=birds.x + 30 > zz.x && birds.x < zz.x + 12 && birds.y+30 <= zz.uheight + 80;
            if(ucheck || dcheck) {
                flying=false;
                mask.style.display='block';
                success.style.display='block';
                co.style.display='none';
              }
            }
        },50)

    }
createzz(300);//第一对柱子
createzz(600);
createzz(900);
createzz(1200);
createzz(1500);
}
